#ifndef BaseScene_H
#define BaseScene_H

#include <amk3/amk3.h>
#include <amk3/SceneContext.h>
#include <osg/Referenced>
#include <osg/Node>
#include <osgEarth/MapNode>
#include <osgEarth/SpatialReference>
#include <osgViewer/Viewer>
#include <osgEarthUtil/EarthManipulator>


class AMK_API BaseScene : public osg::Referenced
{
public:
	BaseScene();
	virtual ~BaseScene();

	virtual osg::Node* createNode();

	virtual void open();

	virtual void close();

	osg::Node* getOrCreateNode();

	osg::Node* getNode();

	void setVisible(bool b);

	SceneContext* getSceneContext();

	inline osg::Vec3 llhToXYZ(osg::Vec3& v){
		if (getSceneContext()->getEllipsoidModel()){
			double x, y, z;
			getSceneContext()->getEllipsoidModel()->convertLatLongHeightToXYZ(
				osg::DegreesToRadians(v.y()), osg::DegreesToRadians(v.x()), v.z(), x, y, z);
			return osg::Vec3(x, y, z);
		}
		return osg::Vec3(0, 0, 0);
	}

protected:
	osg::ref_ptr<osg::Node> _node;
};

class AMK_API EarthScene : public BaseScene 
{
public:
	EarthScene();
	virtual ~EarthScene();

	virtual void open();

	virtual void close();
};

#endif // BaseScene_H